﻿function myShareAll(){
	document.getElementById("shoppingCar_subtitle").style.display="none";
	document.getElementById("myDesignTable").style.display="none";
	document.getElementById("myOrderTable").style.display="none";
	document.getElementById("MyProjectTable").style.display="none";
	document.getElementById("friend_content_right").style.display="none";
	document.getElementById("shareContent").style.display="";
	$(".myfriend_friendactivity_content_right_childtitle_left:gt(0)").remove();
	$(".myfriend_friendactivity_content_right_childtitle_right:gt(0)").remove();
	$(".myfriend_friendactivity_content_right_childtitle_left div:eq(0)").siblings().remove();
	$(".myfriend_friendactivity_content_right_childtitle_right div:eq(0)").siblings().remove();
	showMyParticipate();
 }

function showMyParticipate(){
	$("#all_share_content_myshare_out").empty();
	$("#myJoinInShare").empty();
	$.getJSON("getMyParticipate.action",{
		d:new Date().getTime()
	},
	function(data) {
		$("#myShare_count").html(data.myShareSize);
		$("#partinshare_count").html(data.joinInShareSize);
		$(".myfriend_friendactivity_content_right_select_myshare .myfriend_friendactivity_content_right_select_order_down").html("("+data.myAllShareSize+")");
		showEach(data.plist,"all_share_content_myshare_out",0);//参数：数据源，DIV_ID，起始编号
		$("#all_share_content_myshare_out").append("<div id='itemcontainer' class='holder'></div>");
		jPagesresign("all_share_content_myshare_out","#itemcontainer");
	});
}

function showMyJoinInShare(){
	$("#all_share_content_myshare_out").empty();
	$("#myJoinInShare").empty();
	$("#all_share_content_myshare_out").attr("style","");
	$.getJSON("showMyJoinInShare.action",{
		d:new Date().getTime()
	},
	function(data) {
		$("#myShare_count").html(data.myShareSize);
		$("#partinshare_count").html(data.joinInShareSize);
		$(".myfriend_friendactivity_content_right_select_myshare .myfriend_friendactivity_content_right_select_order_down").html("("+data.myAllShareSize+")");
		showEach(data.plist,"myJoinInShare",0);//参数：数据源，DIV_ID，起始编号
		$("#myJoinInShare").append("<div id='itemcontainer1' class='holder'></div>");
		jPagesresign("myJoinInShare","#itemcontainer1");
		$("#itemcontainer1").show();
	});
}

			//-----------------------------------------------------------------------------
			function showmyshareothercomment(customId){
				$("#"+customId+"commentContent_all").show(500,function(){
					$("#"+customId+"commentContent_all").click(function(){
						$("#"+customId+"commentContent_all").hide();
					});
				});
			}
			 function showmyparticipation(){
				 $("#all_share_content_myshare_out").hide();
				 $("#all_share_content_myparticipation_out").show();
			 }
			 function openreportdialogs(name,commentId){
				 	$("#reportdialog").dialog({
				 		  resizable:false,
			        	  autoOpen:true,
			              module : true,
			              width:600,
			              height:300,
			              position:[getLeft(600),getTop(300)],//定位
			              title: "我要投诉他",
			              open:function(){
			            	  	$("#reportdialog").append(reportstr_sp).fadeIn();
			            	  	$("#beReportName").val(name);
			              },
			              close: function(event, ui){
			            	  	$("#reportdialog").html("");
			              },
			              buttons:{
			            	  '提交' :function(){
			            		  var Content=document.getElementById("reportContent").value;
							    	if(Content==null||Content==""){
							    		OpenTheSHowDialog("亲，您还没有输入举报的理由呢！");
							    	}else{
							    		$.post('SendReportByAjAxAction',{'beReportName':name,'commentId':commentId,'reprotContent':Content},function(data){//传入的值和返回来的值
											if(data =="true"){
												 OpenTheSHowDialog("举报成功！我们会尽快处理！");
												$("#reportdialog").dialog('close');
											}else if(data=="false"){
												alert("举报失败");
												$("#reportdialog").dialog('close');
											}
								    	});
							    	}
			            	  },
			            	  '取消':function(){
			            		  $(this).dialog('close');
			            	  }
			              },
				 		
				 	});
			 }
			 function openprivatedialogs(name){
				 $("#register-form").dialog({
					 resizable:false,
		        	  autoOpen:true,
		              module : true,
		              width:600,
		              height:450,
		              position:[getLeft(600),getTop(450)],//定位
		              title: "找他私聊下",
		              open:function(){
		            		  $("#register-form").append(privatetalkstr_sp).fadeIn();
		            		  $("#toName").val(name);
		            		  initSWFUpload3();
		              },
		              close: function(event, ui){
		            	  $("#register-form").html("");
		              },
		              buttons:{
		            	  '提交' :function(){
		            		  content= $("#messagContent").val();
		            		  if(content==null||content==""){
		            			  OpenTheSHowDialog("亲，您还没写私聊内容！");
		            		  }else{
		            			  if(upload3.getStats().files_queued !== 0){
		            				  sendswf3();
			            		  }else if(upload3.getStats().files_queued === 0){
			            				//alert("file is null");
			            			  $.post('SwfSuccessToDateBase',{'toName':$("#toName").val(),'filesName':"",'messageContent':$("#messagContent").val()},function(data){
			            					if(data=="true"){
			            						OpenTheSHowDialog("您的私聊已经发到");
			            						$("#register-form").dialog("close");
			            					}else{
			            						OpenTheSHowDialog("发送失败");
			            						$("#register-form").dialog("close");
			            					}
			            				});
			            			
			            		  }
		            		  }
		            	  },
		            	  '取消':function(){
		            		  $(this).dialog('close');
		            	  }
		              },
				 });
			 }
			 function newData(d){
					var i=d.indexOf("T");
					var str=" "+d.substr(0,i)+" "+d.substr(i+1,d.length);
					return str;
					
				}
			 function ShowMoreComment(Customid){
					alert(Customid);
					window.open("ShareInfo?_id="+Customid);
				}
			 function CustomUploadFiledialog(customId,toName,sourse){
				 //alert(customId+","+toName+","+sourse);
				 $("#register-form").dialog({
					 resizable:false,
		        	  //show: "slide",
		        	  autoOpen:true,
		              module : true,
		              width:600,
		              height:400,
		              position:[getLeft(600),getTop(250)],//定位
		              title: "给他单独发个文件看",
		              open:function(){
		            		  $("#register-form").html(customuploadfilestr_sp).fadeIn();
		            		  initSWFUpload4(customId,toName,sourse);
		              },
		              close: function(event, ui){
		            	  $("#register-form").html("");
		              },
		              buttons:{
		            	  '提交' :function(){
		            		  if(upload4.getStats().files_queued === 0){
		            			  OpenTheSHowDialog("无任何文件，您先选择文件");
		            		  }else{
		            			  sendswf4();
		            		  }
		            	  },
		            	  '取消':function(){
		            		  $(this).dialog('close');
		            	  }
		              },
				 });
			 }
			 function sendPartInShareComment(orderId,sourse){
				 if(sourse==0){
					//alert(orderId);
					 var content=$("#"+orderId+"textContentmyparticipation").val();
					 if(content==null||content==""){
						 OpenTheSHowDialog("亲，请输入内容哦");
					 }else{
						 $.post('CommentFriendCustomsByAjAxAction?time='+Math.random(),{'customid':orderId,'textContent':content,'sourse':sourse},function(data){
							 	if(data=="success"){
							 		$("#"+orderId+"textContentmyparticipation").val("");
							 		$.getJSON('GetTheLastCommentByCustomId?time='+Math.random(),{'CustomId':orderId,'sourse':sourse},function(data){
							 			$("#"+orderId+"commentContentmyparticipation").html("");
							 			$("#"+orderId+"commentContentmyparticipation").append("<span style='float:left;'><a href='getFriendOwnMessageAction?uname="+data.comment.userName+"'>"+data.comment.userName+"</a>:"+data.comment.commentContent+ newData(data.comment.commentTime)+"</span>");
							 			$("#"+orderId+"commentContentmyparticipation").append("<span style='float: right'><a style='font-size:11px;' href='javascript:void(0);' onclick='openreportdialogs(\""+data.comment.userName+"\","+data.comment.commentId+")'>投诉他</a>|<a style='font-size:11px;' href='javascript:void(0);' onclick='openprivatedialogs(\""+data.comment.userName+"\")'>私聊</a></span><br/><br/>");
							 			$("#"+orderId+"partinsharecomemntcount").html(data.commentCountbycustomid);
							 		});
							 		 OpenTheSHowDialog("评论成功了！");
							 	}else{
							 		$("#"+orderId+"textContentmyparticipation").val("");
							 		OpenTheSHowDialog("评论失败！");
							 	}
						 });
					 }
				 }else if(sourse==1){
					 var content=$("#"+orderId+"textContentmyparticipationnopay").val();
					 if(content==null||content==""){
						 OpenTheSHowDialog("亲，请输入内容哦");
					 }else{
						 $.post('CommentFriendCustomsByAjAxAction?time='+Math.random(),{'customid':orderId,'textContent':content,'sourse':sourse},function(data){
							 	if(data=="success"){
							 		$("#"+orderId+"textContentmyparticipationnopay").val("");
							 		$.getJSON('GetTheLastCommentByCustomId?time='+Math.random(),{'CustomId':orderId,'sourse':sourse},function(data){
							 			$("#"+orderId+"commentContentmyparticipation_nopay").html("");
							 			$("#"+orderId+"commentContentmyparticipation_nopay").append("<span style='float:left;'><a href='getFriendOwnMessageAction?uname="+data.comment.userName+"'>"+data.comment.userName+"</a>:"+data.comment.commentContent+ newData(data.comment.commentTime)+"</span>");
							 			$("#"+orderId+"commentContentmyparticipation_nopay").append("<span style='float: right'><a style='font-size:11px;' href='javascript:void(0);' onclick='openreportdialogs(\""+data.comment.userName+"\","+data.comment.commentId+")'>投诉他</a>|<a style='font-size:11px;' href='javascript:void(0);' onclick='openprivatedialogs(\""+data.comment.userName+"\")'>私聊</a></span><br/><br/>");
							 			$("#"+orderId+"partinsharecomemntcount_nopay").html(data.commentCountbycustomid);
							 		});
							 		 OpenTheSHowDialog("评论成功了！");
							 	}else{
							 		$("#"+orderId+"textContentmyparticipationnopay").val("");
							 		OpenTheSHowDialog("评论失败！");
							 	}
						 });
					 }
				 }
				 
			 }
			 
			
			 function DoPartInShareJpages(){
					$("div.holder").jPages({
					    containerID :"all_share_content_myparticipation",
						first: '首页',
						last: '尾页',
						previous: '上页',
						next: '下页',
					    perPage:2,
						callback: function( pages, items ){
							items.showing.find("img").trigger("turnPage");
							items.oncoming.find("img").trigger("turnPage");
						}
					});
				}
			function DoMyShareJpages(){
					$("div.holder4").jPages({
					    containerID :"all_share_content_myshare",
						first: '首页',
						last: '尾页',
						previous: '上页',
						next: '下页',
					    perPage:2,
						callback: function( pages, items ){
							items.showing.find("img").trigger("turnPage");
							items.oncoming.find("img").trigger("turnPage");
						}
					});
				}
			 function showMyshare(){
				 $("#all_share_content_myshare_out").show();
				 $("#all_share_content_myparticipation_out").hide();
			 }
			  function initSWFUpload4(customId,toName,sourse) {
					var settings = {
						flash_url : "swfupload/swfupload.swf",
						 upload_url: "CustomUpdateFileAction",
						 post_params: {"customId":customId,"toName":toName,"sourse":sourse},
						file_size_limit : "100 MB",
						file_post_name: "files",
						file_types : "*.*",
						file_types_description : "All Files",
						file_upload_limit : 100,
						file_queue_limit : 0,
						custom_settings : {
							progressTarget : "fsUploadProgress4",
							cancelButtonId : "btnCancel4"
						},
						debug: false,

						//button_image_url: "img/51.png",
						button_width: "80",
						button_height: "29",
						button_placeholder_id: "spanButtonPlaceholder4",
						button_text: '<span class="theFont">选取文件</span>',
						button_text_style: ".theFont { font-size: 16; }",
						button_text_left_padding: 12,
						button_text_top_padding: 3,
						
						// The event handler functions are defined in handlers.js
						file_dialog_start_handler : fileDialogStart_action,
						file_queued_handler : fileQueued_action,
						file_queue_error_handler : fileQueueError_action,
						file_dialog_complete_handler : fileDialogComplete_action,
						upload_start_handler : uploadStart_action,
						upload_progress_handler : uploadProgress_action,
						upload_error_handler : uploadError_action,
						upload_success_handler : uploadSuccess_action,
					    upload_complete_handler : uploadComplete_action
					};
					upload4 = new SWFUpload(settings);
			     };
			     function initSWFUpload3() {
						var settings = {
							flash_url : "swfupload/swfupload.swf",
							 upload_url: "PrivateTalkSWFUploadAction",
							 post_params: {"toName" :$("#toName").val()},
							file_size_limit : "100 MB",
							file_post_name: "file",
							file_types : "*.*",
							file_types_description : "All Files",
							file_upload_limit : 2,
							file_queue_limit : 0,
							custom_settings : {
								progressTarget : "fsUploadProgress3",
								cancelButtonId : "btnCancel3"
							},
							debug: false,

							//button_image_url: "img/51.png",
							button_width: "80",
							button_height: "29",
							button_placeholder_id: "spanButtonPlaceholder3",
							button_text: '<span class="theFont">选取文件</span>',
							button_text_style: ".theFont { font-size: 16; }",
							button_text_left_padding: 12,
							button_text_top_padding: 3,
							
							// The event handler functions are defined in handlers.js
							file_dialog_start_handler : fileDialogStart_privateTalk,
							file_queued_handler : fileQueued_privateTalk,
							file_queue_error_handler : fileQueueError_privateTalk,
							file_dialog_complete_handler : fileDialogComplete_privateTalk,
							upload_start_handler : uploadStart_privateTalk,
							upload_progress_handler : uploadProgress_privateTalk,
							upload_error_handler : uploadError_privateTalk,
							upload_success_handler : uploadSuccess_privateTalk,
						    upload_complete_handler : uploadComplete_privateTalk,
						};
						upload3 = new SWFUpload(settings);
				     };
		var upload3;
		var upload4;
		function sendswf3(){
			upload3.startUpload();
		}
		function sendswf4(){
			upload4.startUpload();
		}
		
		function getTop(height){
			var windowheight=window.innerHeight;
			return (windowheight-height)/2;
		}
		function getLeft(width){
			var windowwidth=window.innerWidth;
			return (windowwidth-width)/2;
		}
		function toButton(){
			$("button").button();
		}
		function OpenTheSHowDialog(message){
			$("#report_success").html(message).dialog({
				autoOpen:true,
				width:300,
				height:180,
				position:[getLeft(300),getTop(180)],
				buttons:{
					确定:function(){
						$(this).dialog("close");
					}
				}
			});
		}
		function showParticipateDetail(id, type) {
			window.location.href = "showParticipateDetail.action?id=" + id + "&&type="
					+ type;
		}
var reportstr_sp="<div id='report_div' align='center'>"+
		"<table align='center' bgcolor='#FFFAFO'>"+
			"<tr>"+
				"<td>"+
					"举报他"+
				"</td>"+
				"<td>"+
					"<input type='text' name='beReportName' id='beReportName' readonly='readonly' size='30px'/><br/>"+
				"</td>"+
			"</tr>"+
			"<tr>"+
				"<td>"+
					"举报情况:"+
				"</td>"+
				"<td>"+
					"<textarea rows='6' cols='70' name='reportContent' id='reportContent'></textarea><br/>"+
				"</td>"+
			"</tr>"+
		"</table>"+
	"</div>";
var customuploadfilestr_sp="<div id='customuploadfilestrdiv' align='center'>"+
								"<table align='center' bgcolor='#FFFAFO'>"+
									"<tr>"+
										"<td colspan='2'>"+
											"<div class='fieldset flash' id='fsUploadProgress4' style='float: center;'>"+
												"<span class='legend'>文件上传</span>"+
											"</div>"+
										"</td>"+
									"</tr>"+
									"<tr>"+
										"<td>"+
											"<span id='spanButtonPlaceholder4'></span>"+
										"</td>"+
										"<td>"+
											"<input id='btnCancel4' type='button' value='Cancel Uploads' onclick='cancelQueue(upload4)' disabled='disabled' style='margin-left: 2px; height: 22px; font-size: 8pt;' />"+
										"</td>"+
									"</tr>"+
								"</table>"+
						"</div>";
var privatetalkstr_sp="<div id='privatemessage' align='center' style='background-color:#FFFAFO;'>"+
"<table align='center'>"+
	"<tr>"+
		"<td>"+"发给:"+"</td>"+
		"<td>"+
			"<input type='text' name='toName' id='toName' readonly='readonly'/>"+
		"</td>"+
	"</tr>"+
	"<tr>"+
			"<td>"+"内容:"+"</td>"+
			"<td>"+
				"<textarea rows='6' cols='70' name='messagContent' id='messagContent'></textarea>"+
			"</td>"+
	"</tr>"+
"</table>"+
"<div align='center'>"+
	"<table>"+
		  "<tr>"+
				"<td>"+
					"<div align='right'>"+
						"<span id='spanButtonPlaceholder3'></span>"+
					"</div>"+
				"</td>"+
				"<td>"+
					"<div align='left'>"+
						"<input id='btnCancel3' type='button' value='取消上传的文件' onclick='cancelQueue(upload3)' disabled='disabled' style='margin-left: 2px; height: 22px; font-size: 8pt;' />"+
					"</div>"+
				"</td>"+
		  "</tr>"+
	      "<tr>"+
			"<td colspan='2' align='center'>"+
				"<div class='fieldset flash' id='fsUploadProgress3'>"+
					"<span class='legend'>文件上传</span>"+
				"</div>"+
			"</td>"+
      "</tr>"+
	"</table>"+
"</div>"+
"</div>";